﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Diagnostics;
using DBWTProject.persistence;
using System.Xml;
using System.Xml.Linq;
using System.IO;
using DBWTProject.models;

namespace DBWTProject.useradministration
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string username = txbUser.Text;
            string pw = txbPw.Text;

            Debug.WriteLine(username);
            Debug.WriteLine(pw);

            //test, obs ihn gibt
            User user = RouteDAO.GetUser(username, pw);
            if (user != null)
            {//Erfolgreicher Login
                Session[Constants.SESSIONVAR_CURRENTUSER] = user;
                Response.Redirect("/route/MyRoutes.aspx");
            }
            else
            {//Falscher Login -> Fehlermeldung
                lblError.Text = "User or password where incorrect. Please try again.";
            }



            
        }


    }
}